|
|
 |
|
|
|
|
lstNames.Clear
Do Until oRS.EOF
With lstNames
.AddItem Trim$(oRS("szLast_nm")) & ", " & _
Trim$(oRS("sFirst_nm"))
.ItemData(.NewIndex) = oRS("lEmp_id")
End With
oRS.MoveNext
Loop
oRS.Close
If lstNames.ListCount Then
lstNames.ListIndex = 0
End If End Sub |
|
|
|
|
|
|
|
|
As you can see, this code is almost exactly the same as the code you just learned about in the last section. Notice that youre loading the last name and first name into the List() property with the AddItem method, and youre loading the employee ID into the ItemData() property at the same location. The only difference in this routine is that at the end of the procedure, you force the list box to highlight the first employee in the list by setting the ListIndex property to 0. When this property is set, its just like clicking the list boxthe Click event will fire for this list box. |
|
|
|
|
|
|
|
|
Once a Click event occurs on the Employee list box, you need to display the data for the selected employee in the controls to the right of the list box. You want to display the employees first name, last name, street address, and so on. Lets write the code for the lstNames_Click() event: |
|
|
|
 |
|
|
|
|
Private Sub lstNames_Click()
If lstNames.ListIndex <> -1 Then If FormFind() Then
Call FormShow End If
End If
End Sub |
|
|
|
|
|